package demo;

import helloword.MyService;
import org.apache.thrift.TException;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;

public class TestSimpleServer {

    public static void main(String[] args) throws TTransportException {
        TServerTransport serverTransport = new TServerSocket(8080);
        MyHandler myHandler = new MyHandler();
        //方法的调用handler对象过程封装到了ProcessFunction对象中 iface中定义了几个方法就会有几个ProcessFunction
        MyService.Processor<MyHandler> myHandlerProcessor = new MyService.Processor<>(myHandler);
        TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
        serverArgs.processor(myHandlerProcessor);
        //可以TThreadPool服务器的的参数
        serverArgs.maxWorkerThreads = 100;
        TServer server = new TThreadPoolServer(serverArgs);
        //accept 客户端的请求
        server.serve();
    }
}


